package system;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements Operation{
    @Override
    public void work(BookList bookList) {
        Scanner scan = new Scanner(System.in) ;
        System.out.println("输入你要查找的图书的书名");
         String name = scan.nextLine() ;
        int currentSize = bookList.getUsedSize();
        for(int i = 0 ;i < currentSize ; i ++){
            Book book = bookList.getBook(i) ;
            if (book.getName().equals(name)) {
                System.out.println("找到了");
                System.out.println(book);
                return ;
            }
         }
        System.out.println("不好意思，没有找到这本书");

    }
}
